﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.Windows;

using System.Windows.Input;

using FXnaWpfBase;

using GWApplication;

using FXnaAppBaseWpf;


namespace GWPresentation
{
    public static class DialogCommandBinder
    {


        static RoutedCommand setGeoBoundary = new RoutedCommand();

        public static RoutedCommand SetGeoBoundary
        {
            get { return setGeoBoundary; }
         
        }



           /// <summary>
        /// 将命令绑定到窗体
        /// </summary>
        /// <param name="window"></param>
        public static void BindCommandsToWindow(Window window)
        {

            CommandBinding cbSetGeoBoundary = new CommandBinding();
            cbSetGeoBoundary.Command = setGeoBoundary;
            cbSetGeoBoundary.Executed += new ExecutedRoutedEventHandler(cbSetGeoBoundary_Executed);
            cbSetGeoBoundary.CanExecute += new CanExecuteRoutedEventHandler(cbSetGeoBoundary_CanExecute);

            window.CommandBindings.Add(cbSetGeoBoundary);


        }

        static void cbSetGeoBoundary_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (!ProjectService.CurrentService.BNullProj)
            {

                e.CanExecute = true;
                
            }

           

            e.Handled = true;
        }

        static void cbSetGeoBoundary_Executed(object sender, ExecutedRoutedEventArgs e)
        {


             


              winBoundary win = new winBoundary(ProjectService.CurrentService.Project.CommonData.WorkBoundary);

              if (win.ShowDialog()==true)
              {

                  ProjectService.CurrentService.Project.CommonData.WorkBoundary = win.Boundary;

                  
              }



        }



    }
}
